<template>
	<view>
		<view style=" padding: 0rpx; text-align: center;">
			<image src="/static/hjlogo.png" mode="aspectFit" height='80rpx'></image>
		</view>
		<view class="input-box" style=" border: 1px solid #eee;  border-radius: 20rpx; 	box-shadow: 1px 1px 5px #eee;
 ; width: 90%; margin: 0 auto;">
			<view class="input-item">
				<view class="input-label">账号</view>
				<view class="input-body">
					<input v-model="loginName" maxlength="11" type="text" placeholder="请输入用户名" class="input">
				</view>
			</view>
			<view class="input-item">
				<view class="input-label">密码</view>
				<view class="input-body">
					<input v-model="loginPwd" type="password" :password="isHidePassword?true:false"
						style="margin-right: 50upx;" placeholder="请输入密码" maxlength="20" class="input" />
				</view>
			</view>
			<view class="select" style=" margin-bottom: 100rpx;">
				<!-- <navigator url="/pages/register/register" hover-class="none">注册</navigator> -->
				<navigator @click="wjmm" hover-class="none">忘记密码？</navigator>
			</view>

			<button class="button" @click="submit">登录</button>


		</view>
	</view>
</template>

<script>
	import service from '@/util/service.js'
	import Base64 from 'base-64';
	export default {
		data() {
			return {
				_keyStr: "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",
				loginName: "",
				loginPwd: ""
			}
		},
		onLoad: function() {
			// this.login();
		},
		methods: {



			wjmm: function() {
				uni.showModal({
					title: "系统提示",
					content: "请联系管理员修改密码",
					showCancel: false
				})
			},
			submit: function() {
				var that = this;
				uni.showLoading({
					title: '登陆中..'
				})
				if (this.loginName == "") {
					uni.showModal({
						title: "系统提示",
						content: "请输入账号",
						showCancel: false
					})
					uni.hideLoading();
					return;
				}
				if (this.loginPwd == "") {
					uni.showModal({
						title: "系统提示",
						content: "请输入密码",
						showCancel: false
					})
						uni.hideLoading();
					return;
				}
				var loginpwd2 = Base64.encode(that.loginPwd)
				console.log(loginpwd2);
				service.postJson('/admin/auth/gettoken', {
					loginname: that.loginName,
					loginpwd: loginpwd2
				}, function(res) {
					uni.hideLoading();
					if (res.code == 1) {
						service.setUser(res.data);
						uni.redirectTo({
							url: '../index/index'
						})
					} else {
						uni.showModal({
							title: "系统提示",
							content: res.msg
						})

					}
				})
				return;
				uni.login({
					provider: 'weixin',
					success: function(loginRes) {
						service.postJson('/admin/account/loginbind', {
							LoginName: that.loginName,
							loginPwd: that.loginPwd,
							wxCode: loginRes.code
						}, function(res) {
							uni.hideLoading();
							if (res.Code == 1) {
								service.setUser(res.Data);

								uni.redirectTo({
									url: '../index/index'
								})
							} else {
								uni.showModal({
									title: "系统提示",
									content: res.Msg
								})

							}

						})
					}
				})



			}
		}
	}
</script>

<style lang="scss" scoped>
	button::after {
		border: none;
	}

	.input-box {
		padding: 50upx;
		font-size: 30upx;

		.input-item {
			display: flex;
			background: white;
			border-bottom: 1upx solid #eeeeee;
			line-height: 100upx;
			height: 100upx;

			.input-label {
				width: 150upx;
			}

			.input-body {
				position: relative;
				height: 100upx;
				width: calc(100% - 150upx);

				.input {
					line-height: 100upx;
					height: 100upx;
					position: relative;
					font-size: 28upx;
				}

				.eye {
					position: absolute;
					height: 50upx;
					width: 50upx;
					right: 0;
					top: 50%;
					transform: translateY(-50%);
				}

				.btn-code {
					position: absolute;
					right: 0upx;
					top: 50%;
					transform: translateY(-50%);
					background: none;
					color: #205592;
					width: 160upx;
					font-size: 24upx;
					box-sizing: border-box;
					text-align: right;
					padding: 0;
					height: 100upx;
					line-height: 100upx;
				}
			}

		}

		.select {
			padding-top: 40upx;
			display: flex;
			justify-content: space-between;
			color: #003B67;
		}
	}

	.button {
		margin: 0 30upx;
		background: rgb(24, 181, 102);
		border-radius: 50upx;
		line-height: 80upx;
		height: 80upx;
		color: white;
		font-size: 32upx;
	}
</style>